<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><?php echo C('SITE_INFO.name');?></title>
<script type="text/javascript" src="__PUBLIC__/scripts/jquery-1.7.2.min.js"></script>
<link href="__PUBLIC__/Catalog/css/common.css" rel="stylesheet" type="text/css" />

<link href="__PUBLIC__/Catalog/css/orderlist_xiadan.css" rel="stylesheet" type="text/css" />
<script>
$(function(){
    if('<?php echo ($msg); ?>'!='0'){
        alert('<?php echo ($msg); ?>');
    }
});

function confirmOrder(orderid){
	$('#orderid').val(orderid);
	$('#orderconfirm').css('display','block');
}

function complainOrder(orderid,complaintype){
	$('#sorderid').val(orderid);
	$('#complaintype').val(complaintype);
	$('#complainForm').css('display','block');
}
</script>
</head>
<body>
<div class="main">
   <div class="title">
         <div class="title1">
             <a href="<?php echo U('Membership/index');?>" id="back"> < </a>订单管理
         </div>
   </div>
    <div class="filter">
        <div class="filter2">
           <a href="<?php echo U('Membership/ordermanage');?>?bsflag=1" class="are <?php if($bsflag == 1): ?>filterhot<?php endif; ?>">买入</a>
           <a href="<?php echo U('Membership/ordermanage');?>?bsflag=2" class="supply <?php if($bsflag == 2): ?>filterhot<?php endif; ?>">卖出</a>
        </div>
   </div>
   <div class="filter">
        <div class="filter2">
           <a href="<?php echo U('Membership/ordermanage');?>?bsflag=<?php echo ($bsflag); ?>" class="are <?php if($ostatusid == 0): ?>filterhot<?php endif; ?>">全部订单</a>
           <a href="<?php echo U('Membership/ordermanage');?>?ostatusid=1&bsflag=<?php echo ($bsflag); ?>" class="supply <?php if($ostatusid == 1): ?>filterhot<?php endif; ?>">已下单</a>
       	   <a href="<?php echo U('Membership/ordermanage');?>?ostatusid=3&bsflag=<?php echo ($bsflag); ?>" class="brand <?php if($ostatusid == 3): ?>filterhot<?php endif; ?>">已确认</a>
           <a href="<?php echo U('Membership/ordermanage');?>?ostatusid=5&bsflag=<?php echo ($bsflag); ?>" class="brand <?php if($ostatusid == 5): ?>filterhot<?php endif; ?>">已发货</a>
           <?php if($bsflag == 1): ?><a href="<?php echo U('Membership/ordermanage');?>?ostatusid=6&bsflag=<?php echo ($bsflag); ?>" class="price <?php if($ostatusid == 6): ?>filterhot<?php endif; ?>">已评价</a>
           <?php else: ?>
           		<a href="<?php echo U('Membership/ordermanage');?>?ostatusid=7&bsflag=<?php echo ($bsflag); ?>" class="price <?php if($ostatusid == 7): ?>filterhot<?php endif; ?>">已评价</a><?php endif; ?>
           
        </div>
   </div>
   <div class="list">
   		<?php if(is_array($orderList)): foreach($orderList as $key=>$vo): ?><div class="list2">
	         <dl>
	          <dt><?php if($vo['uid'] == $uid): ?>【购买】<?php else: ?>【出售】<?php endif; ?><a href="<?php echo U('Order/detail');?>?orderid=<?php echo ($vo["order_id"]); ?>&back=morder"><?php echo ($vo["products_name"]); ?></a></dt>
	          <dd>下单时间:<?php echo ($vo["order_date_added"]); ?></dd>
	          <dd>下单用户:<?php echo ($vo["shipping_lastname"]); ?> <?php echo ($vo["tel"]); ?></dd>
	          <dd>
	          	交易方式:<span style="color:#099;"><?php if($vo['order_type'] == 1): ?>线下交易<?php else: ?>线上交易<?php endif; ?></span> &nbsp;&nbsp;&nbsp;&nbsp;
	         	<?php if($ostatusid == 0): ?>订单状态:<span style="color:red;"><?php echo ($vo["os_name"]); ?></span>
	         	<?php else: ?> 
	         		支付状态:<span style="color:red;"><?php if($vo['order_status_id'] >= 2): ?>已支付<?php else: ?>未支付<?php endif; ?></span><?php endif; ?>
	         	
	          </dd>
	          <dd style="text-align:center;">
		          <?php if($vo['publish_uid'] == $uid): ?><!-- 卖家订单处理操作 -->
		          	<?php if( $vo['order_type'] == 0): ?><!-- 在线支付，已支付未确认 -->
		          		<?php if( $vo['order_status_id'] == 2): ?><a href="<?php echo U('Order/confirmOrder');?>?orderid=<?php echo ($vo["order_id"]); ?>" class="a1">确认订单</a><?php endif; ?>
		          	<?php else: ?><!-- 线下支付 ,未确认-->
		          		<?php if($vo['order_status_id'] < 3): ?><a href="<?php echo U('Order/confirmOrder');?>?orderid=<?php echo ($vo["order_id"]); ?>" class="a1">确认订单</a><?php endif; endif; ?>
		          	 <?php if( $vo['order_status_id'] < 3): ?><a href="<?php echo U('Order/deleteOrder');?>?orderid=<?php echo ($vo["order_id"]); ?>&dtype=1" class="a1">取消订单</a>
			          	<?php if($vo['order_status_id'] < 1): ?><a href="javascript:complainOrder('<?php echo ($vo["order_id"]); ?>','3')" class="a1">订单申诉</a><?php endif; ?>
			         <?php elseif($vo['order_status_id'] == 3): ?>
			         	<a href="javascript:confirmOrder('<?php echo ($vo["order_id"]); ?>');" class="a1">发货</a>
			         <?php elseif($vo['order_status_id'] == 5): ?>
			         	<a href="javascript:complainOrder('<?php echo ($vo["order_id"]); ?>','3')" class="a1">订单申诉</a>
			         	<a href="<?php echo U('Express/getorder');?>?name=<?php echo ($vo["delivery_company"]); ?>&order=<?php echo ($vo["delivery_num"]); ?>&orderid=<?php echo ($vo["order_id"]); ?>" class="a1">查看物流</a>
			         	<!-- <a href="javascript:getorder('<?php echo ($vo["delivery_company"]); ?>','<?php echo ($vo["delivery_num"]); ?>');" class="a1">查看物流</a> -->
			         <?php elseif($vo['order_status_id'] == 6): ?>
			          	<a href="<?php echo U('Order/sappraise');?>?orderid=<?php echo ($vo["order_id"]); ?>&atype=1" class="a1">交易评价</a>
			          	<a href="javascript:complainOrder('<?php echo ($vo["order_id"]); ?>','3')" class="a1">订单申诉</a>
			         <?php elseif($vo['order_status_id'] == 7): ?>
			          	<a href="" class="a1">已完成</a>
			         <?php elseif($vo['order_status_id'] == 8 or $vo['order_status_id'] == 7): ?>
			         	<a href="javascript:complainOrder('<?php echo ($vo["order_id"]); ?>','3')" class="a1">订单申诉</a>
			         <?php elseif($vo['order_status_id'] == 9): ?>
			         	<a href="#" class="a1">申诉中...</a><?php endif; ?>
		          <?php else: ?>
		          <!-- 买家订单处理操作 -->
		          	<?php if($vo['order_type'] == 0 && $vo['order_status_id'] == 1): ?><a href="<?php echo U('Order/payment');?>?orderid=<?php echo ($vo["order_id"]); ?>" class="a1">付款</a><?php endif; ?>
		          	<?php if($vo['order_type'] == 1): if($vo['products_type'] != 3): ?><a href="#" class="a1">在线支付</a><?php endif; endif; ?>
		          	 <?php if($vo['order_status_id'] < 3): ?><a href="<?php echo U('Order/deleteOrder');?>?orderid=<?php echo ($vo["order_id"]); ?>&dtype=0" class="a1">取消订单</a>
			          <?php elseif($vo['order_status_id'] == 3): ?>
			         	 <a href="javascript:complainOrder('<?php echo ($vo["order_id"]); ?>','2')" class="a1">订单申诉</a>
			          <?php elseif($vo['order_status_id'] == 5): ?>
			          	<a href="<?php echo U('Order/appraise');?>?orderid=<?php echo ($vo["order_id"]); ?>&atype=0" class="a1">收货评价</a>
			          	<a href="<?php echo U('Express/getorder');?>?name=<?php echo ($vo["delivery_company"]); ?>&order=<?php echo ($vo["delivery_num"]); ?>&orderid=<?php echo ($vo["order_id"]); ?>" class="a1">查看物流</a>	
			          	<a href="javascript:complainOrder('<?php echo ($vo["order_id"]); ?>','2')" class="a1">订单申诉</a>		          	
			          <?php elseif($vo['order_status_id'] == 7 or $vo['order_status_id'] == 6 ): ?>
			          	<a href="" class="a1">已完成</a>
			          	<a href="javascript:complainOrder('<?php echo ($vo["order_id"]); ?>','2')" class="a1">订单申诉</a>
			          <?php elseif($vo['order_status_id'] == 9 or $vo['order_status_id'] == 8): ?>			          	
			          	<a href="#" class="a1">申诉中...</a><?php endif; endif; ?>
	          </dd>
	        </dl>
	      </div><?php endforeach; endif; ?>
   </div>
   <!-- 确认物流信息 -->
<div class="foot1" style="display:none;" id="orderconfirm">
    <div class="foot2">
        <span class="foot2i">请填写物流信息：</span>
        <a class="foot2x" onclick="javascript:$('#buyconfirm').css('display','none');" ></a>
    </div>
    <div class="foot2Select">
    	<form action="<?php echo U('Order/sendOrder');?>" method="post">
	    	<input type="hidden" name="orderid" id="orderid" value=""/>
	    	<p><br/></p>
	    	<p>快递公司：
	    	<select name="deliveryCompany" required>
	    		<?php if(is_array($express)): foreach($express as $key=>$vo): ?><option value="<?php echo ($vo["express_name"]); ?>"><?php echo ($vo["express_name"]); ?></option><?php endforeach; endif; ?>
	    	</select>
	    	<!-- <input class="oinput" type="text" name="deliveryCompany" id="deliveryCompany" value="" required /> --></p>
	    	<p><br/></p>
	    	<p>快递单号：<input class="oinput" type="text" name="deliveryNum" id="deliveryNum" value="" required/></p>
	        <p><input type="submit" class="go" value="提交信息"/></p>
        </form>
    </div>
</div>
  <!-- 交易申诉信息 -->
<div class="foot1" style="display:none;" id="complainForm">
    <div class="foot2">
        <span class="foot2i">请填写申诉信息：</span>
        <a class="foot2x" onclick="javascript:$('#complainForm').css('display','none');" ></a>
    </div>
    <div class="foot2Select">
    	<form action="<?php echo U('Order/complain');?>" method="post">
	    	<input type="hidden" name="orderid" id="sorderid" value=""/>
	    	<input type="hidden" name="complaintype" id="complaintype" value="" />
	    	<p><br/></p>
	    	<p><textarea rows="10" cols="47" name="complaintext"  placeholder="请简单描述您遇到的问题" required></textarea></p>
	        <p><input type="submit" class="go" value="提交申诉"/></p>
        </form>
    </div>
</div>
<script>
function getorder(oname,oderid){
	alert(oname);
	$.ajax({
		type:"post",
		url:"<?php echo U('Express/getorder');?>",
		datatype:'json',
		data:{name:oname,order:orderid},
		success:function(result){
			datacontent =window.JSON.parse(result);
			if(datacontent.flag==1){
				alert(datacontent.msg);
			}else {
				alert(datacontent.msg);
			}
			
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert(XMLHttpRequest.status);
			alert(XMLHttpRequest.readyState);
			alert(textStatus);
		},
	});
}

</script>
<div class="index-foot">
    <div class="index-foot2">
            <ul>
              <li>
                  <dl>
                      <dd class="index-dds"><a href="<?php echo U('Index/index');?>"><img src="__PUBLIC__/Catalog/images/house.png" /></a></dd>
                      <dd><a href="<?php echo U('Index/index');?>">首页</a></dd>
                  </dl>
              </li>
              <li>
                  <dl>
                      <dd class="index-dds"><a href="<?php echo U('Products/index');?>"><img src="__PUBLIC__/Catalog/images/cate1.png" /></a></dd>
                      <dd><a href="<?php echo U('Products/index');?>">商品</a></dd>
                  </dl>
              </li>
              <li>
                  <dl>
                      <dd><a href="<?php echo U('Mproducts/publish');?>"><img src="__PUBLIC__/Catalog/images/jia.png"style=" width:50px; height:50px;" /></a></dd>
                  </dl>
              </li>
              <li>
                  <dl>
                      <dd class="index-dds"><a href="<?php echo U('Membership/leaveword');?>"><img src="__PUBLIC__/Catalog/images/<?php if($count > 0): ?>message-hot.png<?php else: ?>message.png<?php endif; ?>" /></a></dd>
                      <dd><a href="<?php echo U('Membership/leaveword');?>">信息</a></dd>
                  </dl>
              </li>
              <li>
                  <dl>
                      <dd class="index-dds"><a href="<?php echo U('Membership/index');?>?uid=<?php echo ($uid); ?>"><img src="__PUBLIC__/Catalog/images/men.png" /></a></dd>
                      <dd><a href="<?php echo U('Membership/index');?>?uid=<?php echo ($uid); ?>">我的</a></dd>
                  </dl>
              </li>
            </ul>       
    </div>
</div>
</body>
</html>